package com.sqx.modules.tbOrders.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sqx.common.utils.Result;
import com.sqx.modules.tbOrders.dao.IllegalTypeDao;
import com.sqx.modules.tbOrders.entity.IllegalType;
import com.sqx.modules.tbOrders.service.IllegalTypeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.ObjectUtils;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@Service
public class IllegalTypeServiceImpl extends ServiceImpl<IllegalTypeDao, IllegalType> implements IllegalTypeService {


    @Autowired
    private HttpServletRequest request;
    @Override
    public Result selectIllegalTypeList() {
        List<IllegalType> illegalTypes = baseMapper.selectList(new QueryWrapper<>());
        return Result.success().put("data", illegalTypes);
    }

    @Override
    public Result selectIllegalTypePage(Integer page, Integer limit,IllegalType illegalType) {
        Page<IllegalType> pages=new Page<>(page,limit);
        IPage<IllegalType> evaluateIPage = baseMapper.selectPageByLanguageType(pages, illegalType);
        return Result.success().put("data", evaluateIPage);
    }

    @Override
    public Result insertIllegalType(IllegalType illegalType) {
        baseMapper.insert(illegalType);
        return Result.success();
    }

    @Override
    public Result updateIllegalType(IllegalType illegalType) {
        baseMapper.updateById(illegalType);
        return Result.success();
    }

    @Override
    public Result deleteIllegalType(Long id) {
        baseMapper.deleteById(id);
        return Result.success();
    }

}
